﻿using System;
using System.Data.Linq.Mapping;
using CoreLibrary.Date;
using IBBI.DataBase.Enumeration;

namespace IBBI.DataBase.Persistent {

    [Table(Name = "IBBI_USER")]
    public class User {

        [Column(Name = "ID", IsDbGenerated = true, IsPrimaryKey = true)]
        public int Id                 { get; set; }

        [Column(Name = "EMAIL")]
        public string Email           { get; set; }

        [Column(Name = "PASSWORD")]
        public string Password        { get; set; }

        [Column(Name = "TITLE")]
        public string Title           { get; set; }

        [Column(Name = "FIRST_NAME")]
        public string FirstName       { get; set; }

        [Column(Name = "MIDDLE_NAME")]
        public string MiddleName      { get; set; }

        [Column(Name = "LAST_NAME")]
        public string LastName        { get; set; }

        [Column(Name = "SEX")]
        public int Sex                { get; set; }

        [Column(Name = "ROLE")]
        public int Role               { get; set; }

        [Column(Name = "ENABLED")]
        public bool Enabled           { get; set; }

        [Column(Name = "DATE_CREATED")]
        public DateTime DateCreated   { get; set; }

        [Column(Name = "DATE_UPDATED")]
        public DateTime DateUpdated   { get; set; }

        [Column(Name = "IP_LAST_LOG_IN")]
        public string   IpLastLogIn     { get; set; }

        [Column(Name = "DATE_LAST_LOG_IN")]
        public DateTime DateLastLogIn { get; set; }

        public User() {
            DateCreated   = DateTime.UtcNow;
            DateUpdated   = DateUtil.Epoch;
            DateLastLogIn = DateUtil.Epoch;
            IpLastLogIn   = string.Empty;
            Enabled       = false;
            Role          = UserRoles.Member.Value;
        }

    }
}